<%@ page language="java"  pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<%=path%>/styles/main.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/js/dialog/skin/ymPrompt.css"  rel="stylesheet" id='skin' type="text/css"/> 

<script type="text/javascript" src="<%=path %>/js/main.js"></script>
<script type="text/javascript" src="<%=path %>/js/dialog/ymPrompt.js" ></script>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.form.js"></script>
<script type="text/javascript">
	
</script>
<script type="text/javascript" language="javascript"> 
	function g(o){return document.getElementById(o);}   
	function HoverLi(n){   
		//如果有N个标签,就将i<=N;   
		for(var i=1;i<=3;i++){g('tb_'+i).className='normaltab';g('tbc_0'+i).className='undis';}g('tbc_0'+n).className='dis';g('tb_'+n).className='hovertab';   
	}  
	 
	function save(){
		var selRoles="";
		var selPris="";
		var roleObj=document.getElementById('usedRole');
		for(var i=0;i<roleObj.options.length;i++){
			selRoles = selRoles+","+roleObj.options[i].value;			
		}

		var priObj=document.getElementById('usedPri');
		for(var i=0;i<priObj.options.length;i++){
			selPris = selPris+","+priObj.options[i].value;			
		}	
		document.getElementById("selRoles").value=selRoles;
		document.getElementById("selPris").value=selPris;

	    var form = $("form[name=userForm]"); 
        var options = {success:showResponse,resetForm:false,dataType:'script'};
        form.ajaxSubmit(options);       
        return;   
	}
	function showResponse(data){//回调函数
	    if(1 == data){
	    	document.getElementById("MsgDiv").innerHTML="保存成功！";
	    	parent.loadPage();	     
	    }else{
	        document.getElementById("MsgDiv").innerHTMNL="操作失败";
	    }
	}    
	function getUserList(obj){
		var deptId=obj.value;		
		$('#empId').empty();
		var selectContainer = $('#empId');
		$.getJSON("<%=path%>/system/employee/getEmpList.do?deptId="+deptId, function(data){
	  		$.each(data.list, function(i,item){	  			
	  			var option = $('<option></option>').text(item.empName).val(item.empId);
	  			selectContainer.append(option);	    	
	  		});
		});
	}
</script>
</head>
<body>
<div id="DetailContent">
	  <!--标签--> 
	  <div id="tb_" class="tb_" >   
		<ul>   
			<li id="tb_1" class="hovertab" onclick="x:HoverLi(1);"> 基本信息</li>   
			<li id="tb_2" class="normaltab" onclick="i:HoverLi(2);"> 角色</li>   
			 <li id="tb_3" class="normaltab" onclick="a:HoverLi(3);"> 权限</li>
		</ul>  			 						
	   </div> 
	<!--内容-->  
	 <form id="userForm" name="userForm"  method="post" action="<%=path %>/system/user/save.do" >  
	 <div class="ctt" style="height:390px;" > 
			<div class="dis" id="tbc_01">
				<table width="100%" border="0" cellpadding="2" cellspacing="2"  align="center"  class="TableForm">
				  <tr>
					<td width="90">部门<span class="redMst">*</span></td>
					<td  class="NTbsM">	  					
       					<s:select  emptyOption="true" name="deptId" style="width:200px;" onchange="getUserList(this)" list="deptList"  listKey="orgId" listValue="orgName" value="deptId" />						
					</td>
					<td width="100">&nbsp;</td>
					<td nowrap="nowrap">姓名<span class="redMst">*</span></td>
					<td class="NTbsM">
						<s:select emptyOption="true" name="empId" style="width:200px;" list="empList"  listKey="empId" listValue="empName" value="empId"/>
					</td>
					<td >&nbsp;</td>
					</tr>
				  <tr>
					<td  nowrap="nowrap">登陆名</td>
					<td class="NTbsM">
						<input name="userId" type="hidden" value="<s:property value="user.userId"/>"/>
						<input name="userName" value="<s:property value="user.userName"/>"　type="text" class="InputText" onfocus="this.className='InputTextDown'" onblur="this.className='InputText'" />
					</td>
					<td width="100">&nbsp;</td>
					<td width="90" nowrap="nowrap">登陆密码</td>
					<td class="NTbsM"><input name="password"  value="<s:property value="user.password"/>" type="text" class="InputText" onfocus="this.className='InputTextDown'" onblur="this.className='InputText'" /></td>
					<td>&nbsp;</td>
				 </tr>				 
				</table>   
			</div> 
	 		<div class="undis" id="tbc_02">
				<table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"  >
					 <tr><td colspan="3" height="10"></td></tr>
					 <tr>					 	
					    <td width="220"><select id="allRole" name="allRole" multiple="true" class="multi_Select">
							 	<s:iterator value="roleAllList">
									<option value="<s:property value="roleId"/>"><s:property value="roleName"/></option>
								</s:iterator> 
							</select>
						</td>
						<td  width="60">
							<input name="btnMoveRoleRight" type="button" class="arrowRGo" onClick="moveSelected(document.getElementById('allRole'),document.getElementById('usedRole'))" value="" /><br /><br />
							<input name="btnMoveRoleLeft" type="button" class="arrowLGo" onClick="moveSelected(document.getElementById('usedRole'),document.getElementById('allRole'))" value="" />  
						</td>		
						<td  width="220"><input type="hidden" name="selRoles" id="selRoles"/>
							<select id="usedRole" name="usedRole" multiple="true" class="multi_Select">
								<s:iterator value="roleUsedList">
									<option value="<s:property value="roleId"/>"><s:property value="roleName"/></option>
								</s:iterator>  
							</select>
						</td>
					 </tr>
			     </table>		  	      
  	 	   </div>   
	 		<div class="undis" id="tbc_03">
				  <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center">
				  	 <tr><td colspan="3" height="10"></td></tr>
					 <tr>
					    <td width="220"><select id="allPri" name="allPri" multiple="true"  class="multi_Select" >
							  <s:iterator value="priAllList">
									<option value="<s:property value="resId"/>"><s:property value="resName"/></option>
								</s:iterator> 
							</select>
						</td>
						<td width="60">
							<input name="btnMovePriRight" type="button" class="arrowRGo" onClick="moveSelected(document.getElementById('allPri'),document.getElementById('usedPri'))" value="" /><br /><br />
							<input name="btnMovePriLeft" type="button" class="arrowLGo" onClick="moveSelected(document.getElementById('usedPri'),document.getElementById('allPri'))" value="" />
						</td>
						<td width="220"><input type="hidden" name="selPris" id="selPris"/>
							<select id="usedPri" name="usedPri" multiple="true"  class="multi_Select" >
							  <s:iterator value="priUsedList">
									<option value="<s:property value="resId"/>"><s:property value="resName"/></option>
								</s:iterator> 
							 </select>
						</td>
					 </tr>
			     </table>       	 
			</div>
	 </div>	 
	</form>
</div>
<!--工具按钮-->
<div  id="FormToobar" style="margin:0 5px;">
	<div id="MsgDiv" style="float:left"></div>
	<div style="float:right">
	    <tt><input name="保存23" type="button" class="But" value="保存" onclick="save()"/> </tt>
	    <tt><input name="返回23" type="button" class="But" value="返回" onclick="parent.ymPrompt.close();" /></tt>
    </div>	
</div>
</body>
</html>
